// pages/fabu/fabu.js
var app = getApp()
Page({
  data: {
    selectPartition: 0,
    msgList: [{
        title: "系统测试中~~~~~"
      },
      {
        title: "我们正在不断进步~~~"
      },
      {
        title: "请关注公众号“艺盏”~~",
      },
      {
        title: "想发布作品可以联系公众号哟~",
      },
      {
        title: "请多多指教~~"
      }
    ],

    
    navbar: ['推荐', '关注'],
    currentTab: 0
  },

  search: function () {
    wx.navigateTo({
      url: '../search/search'
    })
  },

  tapPartition: function (e) {
    // console.log(e.target.dataset)
    // this.selectPartition = e.target.dataset.idx
    this.setData({
      selectPartition: e.target.dataset.idx
    })
    console.log(this.data.selectPartition)
  },


  searchGood: function (e) {

    console.log(this.data.typelist)
    var search_key = e.detail.value.keyword
    console.log(search_key)
    // wx.showToast({
    //   title: "Loading...",
    //   icon: "loading",
    //   duration: 390000
    // })
    var searched = []
    for (var index in this.data.typelist) {
      // console.log(this.data.typelist[index].goods)
      // for (var index in )
      for (var i in this.data.typelist[index].goods) {
        // 所有商品到内容
        var goods_title = this.data.typelist[index].goods[i].title
        if (goods_title.indexOf(search_key) >= 0) {
          var goods = this.data.typelist[index].goods[i]
          console.log(this.data.typelist[index].goods[i])
          searched = searched.concat(goods)

        }
      }
    }
    console.log("searched=", searched)
    var search_results = JSON.stringify(searched)
    wx.navigateTo({
      url: '/pages/searchs/searchs?search_results=' + search_results,
    })
    // 增加进商品搜索结果


  },

  // 跳转到搜索页面
  search: function () {
    wx.navigateTo({
      url: '../search/search'
    })
  },


  navbarTap: function (e) {
    this.setData({
      currentTab: e.currentTarget.dataset.idx
    })
  }
})